import { Controller, Get, Post, Body, Param, Query } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { PresetService } from './preset.service';

@ApiTags('presets')
@Controller('presets')
export class PresetController {
  constructor(private readonly presetService: PresetService) {}

  @Get('categories')
  @ApiOperation({ summary: '获取预设分类' })
  getCategories() {
    return this.presetService.getCategories();
  }

  @Get()
  @ApiOperation({ summary: '获取预设列表' })
  getPresets(
    @Query('category') category?: string,
    @Query('template_type') templateType?: string,
    @Query('tags') tags?: string[]
  ) {
    return this.presetService.getPresets({ category, template_type: templateType, tags });
  }

  @Get(':id')
  @ApiOperation({ summary: '获取预设详情' })
  getPreset(@Param('id') id: string) {
    return this.presetService.getPreset(id);
  }

  @Post(':id/apply')
  @ApiOperation({ summary: '应用预设' })
  async applyPreset(
    @Param('id') id: string,
    @Body() params: Record<string, any>
  ) {
    const preset = await this.presetService.getPreset(id);
    return this.presetService.applyPreset(params, preset);
  }
} 